package com.jic.manager.controller.manage.memstorecontroller;

import com.jic.common.base.vo.Page;
import com.jic.common.base.vo.PageResult;
import com.jic.common.base.vo.RestResult;
import com.jic.manager.request.StoreRatingRequest;
import com.jic.manager.response.StoreRatingResponse;
import com.jic.manager.service.StoreRatingService;
import org.springframework.beans.BeanUtils;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("storeRating")
public class StoreRatingController {
    @Resource
    private StoreRatingService storeRatingService;



    //查询店铺评分列表
    @RequestMapping(value = "/getStoreRatingList")
    public RestResult<PageResult<StoreRatingResponse>> getStoreRatingList(@RequestBody StoreRatingRequest form) {
        StoreRatingRequest storeRatingRequest = new StoreRatingRequest();
        BeanUtils.copyProperties(form, storeRatingRequest);
        PageResult<StoreRatingResponse> mestorePageResult = storeRatingService.queryPage(storeRatingRequest, new Page() {{
            setStart(form.getStart());
            setLimit(form.getLimit());
        }});
        return RestResult.success(mestorePageResult);
    }

    //查询店铺评分详情
    @RequestMapping(value = "/getStoreCommentList")
    public  RestResult<PageResult<StoreRatingResponse>> getStoreCommentList(@RequestBody StoreRatingRequest form){
        StoreRatingRequest storeRatingRequest = new StoreRatingRequest();
        BeanUtils.copyProperties(form, storeRatingRequest);
        PageResult<StoreRatingResponse> commenResult =storeRatingService.getStoreCommentList(storeRatingRequest,new Page(){{
            setStart(form.getStart());
            setLimit(form.getLimit());
        }});
        return RestResult.success(commenResult);
    }

}
